package com.lht.admin.entity;

import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Collections;
import java.util.List;

/**
 * @author: Frank
 * @date: 2019/10/11 18:39
 * @version: V1.0
 */
@Data
@NoArgsConstructor
public class PageInfoDto<T> {

    private long pageNum = 1L;

    private long pageSize = 0L;

    private List<T> records = Collections.EMPTY_LIST;

    private long pages = 0L;

    private long total = 0L;

    public PageInfoDto(IPage<T> page) {
        if (page == null) {
            return;
        }
        this.pageNum = page.getCurrent();
        this.pageSize = page.getSize();
        this.records = page.getRecords();
        this.pages = page.getPages();
        this.total = page.getTotal();
    }

    public void copyProperties(IPage page) {
        if (page == null) {
            return;
        }
        this.pageNum = page.getCurrent();
        this.pageSize = page.getSize();
        this.pages = page.getPages();
        this.total = page.getTotal();
    }
}
